<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="/res/back/css/base.css" rel="stylesheet" type="text/css" />
<link href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />

<script src="/res/common/js/jquery.1.9.1.min.js" type="text/javascript"></script>
<script src="/res/third/bootstrap3/jsone/bootstrap.min.js" type="text/javascript"></script>
<script src="/res/third/artDialog/jquery.artDialog.js" type="text/javascript"></script>
<script src="/res/third/validate/jquery.validate.js" type="text/javascript"></script>
<script src="/res/third/layer/layer.js"></script>

    <link href="/res/back/css/base.css" rel="stylesheet" type="text/css" />
    <link href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <script src="/res/common/js/jquery.1.9.1.min.js" type="text/javascript"></script>
    <script src="/res/third/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="/res/third/easyUI/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script src="/res/third/artDialog/jquery.artDialog.js" type="text/javascript"></script>
    <script src="/res/third/validate/jquery.validate.js" type="text/javascript"></script>
    <script src="/res/third/powerFloat/js/mini/jquery-powerFloat-min.js" type="text/javascript"></script>

    <script type="text/javascript">
	function sosuo(){
		var lpath=location.pathname;
		//var pageNo = $("#pageNo").val();
		$("#soform").attr("action",lpath+"?pageNo="+1);
		$("#soform").submit();
	}

	function importoExcel(ind){
		if(ind==1){
			var excelids="";
	    	var len=$(".checkedchild:checked").length;
	    	if(len==0){
	    		alert("请选择要导出的公司");
	    		return false;
	    	}
	    	$(".checkedchild:checked").each(function(index){
	    		if(index!=(len-1)){
	    			excelids+=$(this).val()+",";
				}else{
					excelids+=$(this).val();
				}
	    	})
	    	$("#exportForm").find("[name='ind']").val(ind);
	    	$("#exportForm").find("[name='ids']").val(excelids);
	    	$("#exportForm").submit();
		}else{
			if(confirm("确认导出所有企业吗")){
				alert("数据量过大，暂不支持")
			}
		}
		 
	}
	$(document).ready(function(){
	    $(".checkfath").click(function(){
	        $(".checkedchild").prop("checked",this.checked);
		});
	});
</script>
<style type="text/css">
	table{table-layout: fixed;}
	td{overflow: hidden;text-overflow:ellipsis;}
	.catecheck{float: left;margin:7px 10px 0px 10px!important;cursor: pointer;}
	.choosecatesli:hover{background-color: #f9f9f9;}
	.catesbtn{border-radius:8px;background-color: #fff;height: 33px;text-align: center;line-height: 32px;color: black;border: 1px solid #e2e2e2;cursor: pointer;}
	.chooseExcelimport{width: 100%;height: 33px;font-size: 12px;font-family: inherit;color: inherit;float: left;}
	.excelbtn{display: inline-block;height: 100%;width: 100px;background-color:#38A4C7;color: #fff;text-align: center;line-height: 35px;cursor: pointer;border-radius:5px;}
	.dosousuo{float:left; width: 76px;height: 35px;background-color:#38A4C7;right: 777px;top:47px;border-radius:5px;text-align: center;line-height: 35px;font-size: 16px;color: #fff;font-weight: bold;cursor: pointer;margin-left: 5px;}
	.showxitong{width: 620px;min-height: 35px;background-color: #fff;position: absolute;right: 2px;top: 47px;border-radius:5px;text-align: left;line-height: 35px;font-size: 16px;color: inherit;font-weight: bold;}
	.xtstyle{font-size: 12px;color: black;}
	.searchinfos{width:214px;display: table;right: 640px;float: left;}
    .center-block{
        display: inline-block;}
    .form-control{
        display: inline-block;
        width: auto;
	}
	.panel.panel-content{
		overflow-y: scroll;
	}
	tr{height:35px}
</style>
</head>

<body>
	<div class="panel panel-info panel-content">


		<div class="panel-heading" style="position: relative;">
			<form id="soform" method="post">
				<table>
					<tr>
						<td>
							<label for="companyname" class="center-block">公司名称：</label>
						</td>
						<td colspan="2">
						<input style="width:180px;" type="text"  class="form-control" name="so_customerinfo" value="${so_customerinfo!}" id="so_search" placeholder="公司名称" data-options="">
						</td>

						<td  style="padding-top: 5px;">
							<label for="companyname" class="center-block">身份类型：</label>
						</td>
						<td>
							<select class="form-control" name="so_cusrole">
                                <option value="" [#if !so_cusrole?? || so_cusrole=='']selected="selected"[/#if]>全部</option>
                                <option value="1" [#if so_cusrole?? && so_cusrole=='1']selected="selected"[/#if]>采购商</option>
                                <option value="2" [#if so_cusrole?? && so_cusrole=='2']selected="selected"[/#if]>供应商</option>
                                <option value="3" [#if so_cusrole?? && so_cusrole=='3']selected="selected"[/#if]>双重身份</option>
                            </select>
						</td>

						<td  style="padding-top: 5px;">
							<label for="companyname" class="center-block">审核状态：</label>
						</td>
						<td>
							<select class="form-control" name="so_cusstate">
                                <option value="" [#if !so_cusstate?? || so_cusstate=='']selected="selected"[/#if]>全部</option>
                                <option value="0" [#if so_cusstate?? && so_cusstate=='0']selected="selected"[/#if]>待审核</option>
                                <option value="1" [#if so_cusstate?? && so_cusstate=='1']selected="selected"[/#if]>待重新审核</option>
                                <option value="2" [#if so_cusstate?? && so_cusstate=='2']selected="selected"[/#if]>退回修改</option>
                                <option value="3" [#if so_cusstate?? && so_cusstate=='3']selected="selected"[/#if]>审核通过</option>
                                <option value="4" [#if so_cusstate?? && so_cusstate=='4']selected="selected"[/#if]>禁用</option>
                            </select>
						</td>
						<td style="padding-left: 10px">
							<div class="input-group">
								<span class="input-group-btn" style="border: 1px solid #ddd;">
									<button class="btn btn-default" type="button" onclick="sosuo()">搜索</button>
								</span>
							</div>
						</td>
					</tr>

					 <tr>
                        <td>
                            <label for="startdate" class="center-block">注册时间范围:</label>
						</td>
						<td>
                            <input  name="so_pub_startdate"  class="form-control"  id="startdate"   value="${so_pub_startdate!}"  style="width:90px;"  />-
						</td>
						<td>
							<input  name="so_pub_enddate"    class="form-control"  id="enddate"     value="${so_pub_enddate!}"    style="width:90px;"  />
                        </td>


                        <td >
                            <label for="startdate2" class="center-block">审核时间范围:</label>
						</td>
						<td>
                            <input  name="so_dead_startdate"  class="form-control"  id="startdate2"  value="${so_dead_startdate!}"  style="width:90px;"  />-
						</td>
						<td>
                            <input  name="so_dead_enddate"  class="form-control"  id="enddate2"  value="${so_dead_enddate!}"  style="width:90px;"  />
                        </td>
                        </tr>

					<tr>
                        <td>
                            <span style="float: right" class="excelbtn" id="importcheck" onclick="importoExcel(1)">导出已选企业</span>
						</td>
						<td>
							<span style="float: right" class="excelbtn" id="importall" onclick="importoExcel(2)">导出所有企业</span>
                        </td>
					</tr>

				</table>
		</form>
		<form id="exportForm" action="/company/imporetComToExcel.do" method="post">
								<input type="hidden" name="ind">
								<input type="hidden" name="ids">
		</form>
		</div>


		<table class="table table-hover table-bordered table-striped table-condensed">
			<thead>
				<tr>
					<th width="3%"><input type="checkbox" class="checkfath"></th>
					<th width="5%">序号</th>
					<th width="12%">企业名称</th>
					<th width="12%">分公司名称</th>
					<th width="12%">所在地</th>
					<th width="20%">主营产品系统</th>
					<th width="8%">身份</th>
					<th width="6%">提交时间</th>
					<th width="6%">状态</th>
					<th width="8%">是否自营</th>
					<th width="22%">操作</th>
				</tr>
			</thead>
			[#list pagination.list as customer]
			<tr>
				<td style="text-align: center;"><input  class="checkedchild" type="checkbox" value="${customer.id!}" ></td>
				<td align="center">${customer_index+1!}</td>
				<td>${customer.companyName!}</td>
				<td>[#if customer.company?? && customer.company?size>0][#list customer.company as branchCompany][#if branchCompany_index<2]【${branchCompany.companyName!}】[/#if][#if branchCompany_index==3]...[/#if][/#list][/#if]</td>
				<td>
					[#if customer.provinceName??]${customer.provinceName}[/#if]
					[#if customer.regcityName??],${customer.regcityName}[/#if]
					[#if customer.regareaName??],${customer.regareaName}[/#if]
				</td>
				<td>${customer.categoryNames!}</td>
				<td>[#if customer.isprovider?? && customer.isprovider==1] 供应商[/#if]
					[#if customer.ispurchaser?? && customer.ispurchaser==1] 采购商[/#if]
				</td>
				<td align="center">${(customer.registertime?string("yyyy-MM-dd"))!}</td>
				<td align="center">${customer.auditStateName!}</td>
				<td align="center">
					[#if ((customer.ifSelf)!0) = 1]
				 	         自营
				 	[#else]
				 	         非自营
				    [/#if]
				</td>
				<td> 
				 <button  class="btn btn-info btn-xs delbtn" onclick="showCompanyDetil('${customer.id!}')">查看详情</button>
				 [#if customer.auditState=3]
				 	  <button type="button" class="btn btn-danger btn-xs delbtn" onclick="toShowUsers('${customer.id}')">查看员工</button>
				 [/#if]
				 <button type="button" class="btn btn-danger btn-xs delbtn" onclick="delCompany(${customer.id!})">删除</button>
				 [#if customer.auditState=0 || customer.auditState=1]
				 <button type="button" class="btn btn-success btn-xs delbtn" onclick="audit('${customer.id}')">审核通过</button>
				 <button type="button" class="btn btn-danger btn-xs delbtn" onclick="sendback('${customer.id}')">退回修改</button>
				 <div id="sendbackdiv" style="display: none;">
				    <input type="hidden" id="sendbackId" value="">
				 	<textarea placeholder="填写审核意见" id="sendbackword" rows="5" cols=""></textarea>
				 	<div class="btn btn-danger btn-xs delbtn" onclick="dosendback()">提交</div>
				 	<div class="btn btn-danger btn-xs delbtn" onclick="nosendback()">取消</div>
				 </div>
				 [/#if]
				 <button style="margin:0" type="button" class="btn btn-primary btn-xs delbtn" onclick="returnvisit(${customer.id})">客户回访</button>
				</td>
			</tr>
			[/#list]
		</table>

		<div class="panel-footer">[@fenye p = pagination form = 'infoForm' /]</div>
		 
	</div>
</body>
</html>
<script type="text/javascript">
var dialog2;
function toShowUsers(companyId){
	top.addTempTab("/company/companyUserList.do?so_companyId="+companyId);
}
function showCompanyDetil(companyId){
	top.addTempTab("/company/showComDetails.do?comid="+companyId);
}
function returnvisit(companyId){
    var index = layer.open({
    	type : 2,
    	content : ['/returnvisit/v_list.do?so_type=2&so_companyid=' + companyId, 'no'],
   		area: ['700px', '500px'], //宽高
    })
}
function audit(id){
				 
		 if(confirm("是否审核通过？")){
			 art.dialog.post({
				  
					url : '/company/ajax_audit.do',
					type : 'post',
					dataType : 'json',
					data : {
						id : id
					},
					beforeSend:function(){
			            art.dialog.tips("审核中...");
			        },
					success : function(data){
						if(data.success){
							alert(data.msg);
							location.reload();
						}else{
							error_msg(data.msg , function(){location.reload();});
						}
					}
			 
			},"数据正在审核中.... ");
		 }
	}
var dialogNewub;
function sendback(id){
	 $("#sendbackId").val(id);
	 if(confirm("是否退回修改？")){
		
		 dialogNewub = art.dialog({
	 	        title: "填写审核意见",
	 	        lock:true,
	 	        content: document.getElementById('sendbackdiv')
	 	    });
	 
	 }
}

//删除公司
function delCompany(companyId){
	 if(confirm("请确认要删除该公司？删除后不可恢复！")){
	   //删除公司操作
			$.ajax({
				   type: "post",
				   dataType:"json",
				   url: "ajax_delCompany.do",
				   data:{id:companyId},
				   beforeSend:function(){
					    art.dialog.tips("删除中...");
				   },
				   success: function(data){//成功的时候调用
					   if(data.sucess){
						   //art.dialog.tips(data.msg);
						   location.reload();
					   }else{
						   //删除失败
						   alert(data.msg);
						   location.reload();
					   }
				   }
			});
	 }
}



$("#startdate").datebox({
    formatter:function(date){
        var y = date.getFullYear();
        var m = date.getMonth()+1;
        var d = date.getDate();
        return y+'-'+m+'-'+d;
    },
    onSelect:function(dateselect){
        //enddate清空
        $('#enddate').datebox('setValue', '');
        $("#enddate").datebox("calendar").calendar({
            validator: function(date){
                return dateselect <= date;
            }
        });
    }
});

$("#enddate").datebox({
    formatter:function(date){
        var y = date.getFullYear();
        var m = date.getMonth()+1;
        var d = date.getDate();
        return y+'-'+m+'-'+d;
    }
})

$("#enddate2").datebox({
    formatter:function(date){
        var y = date.getFullYear();
        var m = date.getMonth()+1;
        var d = date.getDate();
        return y+'-'+m+'-'+d;
    }
})

$("#startdate2").datebox({
    formatter:function(date){
        var y = date.getFullYear();
        var m = date.getMonth()+1;
        var d = date.getDate();
        return y+'-'+m+'-'+d;
    },
    onSelect:function(dateselect){
        //enddate清空
        $('#enddate2').datebox('setValue', '');
        $("#enddate2").datebox("calendar").calendar({
            validator: function(date){
                return dateselect <= date;
            }
        });
    }
})





function nosendback(){
	dialogNewub.close();
}
function dosendback(){
	 var id=$("#sendbackId").val();
	 var auditOpinion=$("#sendbackword").val();
	 
	 art.dialog.post({
		  
			url : '/company/ajax_sendback.do',
			type : 'post',
			dataType : 'json',
			data : {
				id : id,auditOpinion:auditOpinion
			},
			beforeSend:function(){
	            art.dialog.tips("处理中...");
	        },
			success : function(data){
				if(data.success){
					alert(data.msg);
					location.reload();
				}else{
					alert(data.msg);
					location.reload();
				}
			}
	 
	},"数据正在处理中.... ");
}
 
</script>